var app = getApp();
Page({
    data:{
      orderId:0,
      orderDetail:{},
      PayCreditName:""
    },
    onLoad:function(e){
      var that = this;
      var orderId = e.id;
      that.setData({
        orderId: orderId
      });
      //获取积分名称
      wx.request({
        url: app.globalData.host + '/api/Store/GetStoreCreditConfigInfo?storeId=' + app.globalData.storeId,
        success: function (res) {
          console.log("获取积分名称");
          console.log(res);
          if (res.data.Code == 0) {
            that.setData({
              PayCreditName: res.data.Data.PayCreditName
            })
          }
          else {
            wx.showModal({
              title: '提示',
              content: res.data.errMsg,
              showCancel: false
            })
            return;
          }
        }
      })
    },
    onShow : function () {
      var that = this;
      wx.request({
        url: app.globalData.host + '/api/order/GetOrder',
        data: {
          uid: app.globalData.userInfo.Uid,
          oid: that.data.orderId
        },
        success: (res) => {
          console.log(res)
          wx.hideLoading();
          if (res.data.Code != 0) {
            wx.showModal({
              title: '错误',
              content: res.data.Message,
              showCancel: false
            })
            return;
          }
          var order = res.data.Data;
          for (var i = 0; i < order.OrderProductList.length; i++) {
            order.OrderProductList[i].Info.ShowImg = app.globalData.image190_190host + order.OrderProductList[i].Info.ShowImg;
            
          }
          that.setData({
            orderDetail: order
          });
          console.log(order)
        }
      })
      
    },
    wuliuDetailsTap:function(e){
      var orderId = e.currentTarget.dataset.id;
      wx.navigateTo({
        url: "/pages/wuliu/index?id=" + orderId
      })
    },
    onPullDownRefresh: function () {
      // 页面相关事件处理函数--监听用户下拉动作
      wx.stopPullDownRefresh();
    }
    
})